<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:doc="livcos.org/ns/doc"
	xmlns:f="livcos.org/ns/xslt/function"
	xmlns:v="livcos.org/ns/view"
	exclude-result-prefixes="doc f v">

	<xsl:import href="/livcos.org/common/base.xsl"/>
	
	<xsl:template match="doc:image">
    <div id="{@id}" class="block image">
    	<xsl:choose>
        <xsl:when test="@align = 'left'">
          <xsl:attribute name="style">float: <xsl:value-of select="@align"/></xsl:attribute>
        </xsl:when>
        <xsl:when test="@align = 'right'">
          <xsl:attribute name="style">float: <xsl:value-of select="@align"/></xsl:attribute>
        </xsl:when>
        <xsl:when test="@align = 'center'">
          <xsl:attribute name="style">text-align: <xsl:value-of select="@align"/></xsl:attribute>
        </xsl:when>
      </xsl:choose>
    	<v:style ref="{resolve-uri('styles.css')}"/>
    	<img src="{f:ref-to-uri(@view, @ref, '.png')}">
        <xsl:attribute name="alt">
          <xsl:value-of select="doc:label"/>
          <xsl:if test="not(doc:label)"><xsl:value-of select="doc:note"/></xsl:if>
        </xsl:attribute>
        <xsl:if test="normalize-space(@preview-width) != ''">
          <xsl:attribute name="width" select="@preview-width"/>
        </xsl:if>
        <xsl:if test="normalize-space(@preview-height) != ''">
          <xsl:attribute name="height" select="@preview-height"/>
        </xsl:if>
        <xsl:if test="(normalize-space(@preview-width) != '') or (normalize-space(@preview-height) != '')">
          <xsl:attribute name="onclick">
            <xsl:text>Wnd().open(this.src,'</xsl:text>
            <xsl:value-of select="@id"/>
            <xsl:text>', 'menubar=no,location=no,resizable=yes,scrollbars=yes,status=no');</xsl:text>
          </xsl:attribute>
          <xsl:attribute name="style">cursor: pointer</xsl:attribute>
        </xsl:if>
      </img>
      <xsl:if test="normalize-space(doc:note) != ''">
        <div class="image_note">
					<span class="inlineEdit">
						<span class="inlnEd_path" title="note"/>
						<xsl:value-of select="doc:note"/>
					</span>
        </div>
      </xsl:if>
    </div>
  </xsl:template>

</xsl:stylesheet>